package com.tbb.app.base.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.tbb.app.base.entity.User;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.util.Date;

@Data
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(description = "用户VO")
public class UserVO {

    @ApiModelProperty("id，注意不是序号")
    private String id;

    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    @ApiModelProperty("修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    @ApiModelProperty("昵称")
    private String name;

    @ApiModelProperty("账号")
    private String account;

    @ApiModelProperty("地区")
    private String location;

    @ApiModelProperty("性别，0-男，1-女")
    private Integer gender;

    @ApiModelProperty("头像url")
    private String profileImg;

    @ApiModelProperty("背景图url")
    private String backgroundImg;

    @ApiModelProperty("个性签名")
    private String profileText;

    @ApiModelProperty("管理员，0-普通用户，1-管理员")
    private Boolean isAdmin;

    @ApiModelProperty("是否已关注")
    private Boolean isFollowed;

    @ApiModelProperty("关注数，仅查询用户详情时返回值")
    private long followNum;

    @ApiModelProperty("粉丝数，仅查询用户详情时返回值")
    private long followerNum;

    @ApiModelProperty("获赞与收藏数，仅查询用户详情时返回值")
    private long likeCollectNum;

    public UserVO(User user) {
        this.id = user.getId();
        this.createTime = user.getCreateTime();
        this.updateTime = user.getUpdateTime();
        this.name = user.getName();
        this.account = user.getAccount();
        this.location = user.getLocation();
        this.gender = user.getGender();
        this.profileImg = user.getProfileImg();
        this.backgroundImg = user.getBackgroundImg();
        this.profileText = user.getProfileText();
        this.isAdmin = user.getIsAdmin();
    }
}
